package com.xuecheng.content.controller;


import com.xuecheng.api.content.CourseAuditApi;
import com.xuecheng.api.content.model.dto.CourseBaseDTO;
import com.xuecheng.api.content.model.qo.QueryCourseModel;
import com.xuecheng.api.content.model.vo.CourseAuditVO;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.content.convert.CourseAuditConvert;
import com.xuecheng.content.service.CourseBaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class CourseAuditController implements CourseAuditApi {

    @Autowired
    private CourseBaseService courseBaseService;

    @PostMapping("m/course/list")
    public PageVO queryCourseList(PageRequestParams params, @RequestBody QueryCourseModel model) {
        PageVO<CourseBaseDTO> page = courseBaseService.queryCurseListByPage(params, model,null);
        return page;
    }

    @PostMapping("/m/courseReview/approve")
    public void approveCourse(@RequestBody CourseAuditVO auditVO) {
        CourseBaseDTO dto = CourseAuditConvert.INSTANCE.vo2dto(auditVO);
        courseBaseService.approveCourse(dto);
    }

}